package edu.cmsc611.textsimulator;

import java.util.Hashtable;

public class Utilities {
	/*
	 * Store the loop lable with its program counter
	 */
	static private Utilities instance=null;
	private Hashtable<String,Integer> loopPCval;//=new Hashtable<String,Integer>();
	private String loopLabel;
	private int instr;
	private int loopiteration=0;
	

	/**
	 * @return the loopLabel
	 */
	public String getLoopLabel() {
		return loopLabel;
	}

	/**
	 * @param loopLabel the loopLabel to set
	 */
	public void setLoopLabel(String loopLabel) {
		this.loopLabel = loopLabel;
	}

	/**
	 * @return the instr
	 */
	public int getInstr() {
		return instr;
	}

	/**
	 * @param instr the instr to set
	 */
	public void setInstr(int instr) {
		this.instr = instr;
	}

	Utilities(){
		this.loopPCval=new Hashtable<String,Integer>();
		this.loopiteration=0;
	}

	public int getLoopiteration() {
		return loopiteration;
	}

	public void setLoopiteration(int loopiteration) {
		this.loopiteration = loopiteration;
	}

	public void put(String label,int inst)
	{
		this.loopPCval.put(label, inst);
	}
	public Integer getInstructionForLabel(String label)
	{
		if(this.loopPCval.containsKey(label))
			return this.loopPCval.get(label);
		else return null;
	}
	public Hashtable<String, Integer> getloopPCval() {
		return loopPCval;
	}

	public void setloopPCval(Hashtable<String, Integer> looplabel) {
		this.loopPCval = looplabel;
	}
	public static Utilities getInstance(){
		if(instance==null){
			instance=new Utilities();
		}
		return instance;
	}
}
